Date.prototype.Format = function (fmt) { //author: meizz
  let o = {
    "M+": this.getMonth() + 1, //月份
    "d+": this.getDate(), //日
    "h+": this.getHours(), //小时
    "m+": this.getMinutes(), //分
    "s+": this.getSeconds(), //秒
    "q+": Math.floor((this.getMonth() + 3) / 3), //季度
    "S": this.getMilliseconds() //毫秒
  };
  if (/(y+)/.test(fmt)) {
    fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  }
  for (let k in o)
    if (new RegExp("(" + k + ")").test(fmt))
      fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  return fmt;

};
export const getParameter = (url)=> {
  const paraString = url.indexOf('?')===-1?"":decodeURI(url.substring(url.indexOf('?')+1));
  let param = {};
  paraString&&paraString.split("&").forEach(item=>{
    param[item.split("=")[0]] = item.split("=")[1];
  });
  return param;
};
let Currency = {
  USD : {
    code : 'USD',
    currency : '美元',
    referRate : 6.3295
  },
  TWD : {
    code : 'TWD',
    currency : '台币',
    referRate : 0.2163
  },
  VND : {
    code : 'VND',
    currency : '越南盾',
    referRate : 0.0002781
  },
  KRW : {
    code : 'KRW',
    currency : '韩元',
    referRate : 0.005949
  },
  THB : {
    code : 'THB',
    currency : '泰铢',
    referRate : 0.2022
  },
  RMB : {
    code : 'RMB',
    currency : '人民币',
    referRate : 1
  }

};
export const setCurrent =(data)=> {
  switch(data.project){
    case 1101:data.currency=Currency.VND;break;
    case 1201:data.currency=Currency.TWD;break;
    case 1202:data.currency=Currency.KRW;break;
    case 1203:data.currency=Currency.USD;break;
    case 1204:data.currency=Currency.THB;break;
    case 1301:data.currency=Currency.TWD;break;
    case 1302:data.currency=Currency.USD;break;
    case 1303:data.currency=Currency.VND;break;
    case 1402:data.currency=Currency.TWD;break;
    case 1403:data.currency=Currency.USD;break;
    case 1404:data.currency=Currency.KRW;break;
    default: data.currency=Currency.RMB;break;
  }
  return data;
};
export const getLtv =(data,index)=> {
  let arr = data.split(",").slice(0,index);
  return  arr.map((s)=>Number(s)||0).reduce((c,p)=> c+100*p,0)/100;
};

